package main

import (
	"go-backend-simple-scaffold/core"
	"go-backend-simple-scaffold/global"
	"go-backend-simple-scaffold/initialize"
	"go-backend-simple-scaffold/utils"
	"go.uber.org/zap"
)

func main() {
	// 读取配置
	global.GBSS_VP = core.Viper()
	// 初始化日志库
	global.GBSS_LOG = core.Zap()
	// 初始化工具库
	utils.UtilsInit()
	// 替换全局的日志实例
	zap.ReplaceGlobals(global.GBSS_LOG)
	// 初始化数据库连接
	global.GBSS_DB = initialize.Gorm()
	if global.GBSS_DB != nil {
		// 创建数据表
		initialize.RegisterTables()
		// 程序结束前关闭数据库连接
		db, _ := global.GBSS_DB.DB()
		defer db.Close()
	}
	// 启动HTTP服务
	initialize.RunHttpServer()
}
